package MyFront.Controller;

import MyFramePro.Annotation.SystemLog;
import MyFramePro.Domain.ResponseResult;
import MyFramePro.Service.Impl.ArticleServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin    //关于跨域的注解
@RestController
@RequestMapping(value = "/article")
public class ArticleController {

    @Resource
    private ArticleServiceImpl articleService;

    /**
     * 这里查询的是当前的热门文章
     */
    @GetMapping(value = "/hotArticleList")
    @SystemLog(businessName = "查询当前热门文章")   //AOP 切面
    public ResponseResult hotArticleList(){

        return articleService.getHotArticleList();
    }


    /**
     * 这里是进行分页查询文章列表数据
     */
    @GetMapping(value = "/articleList")
    @SystemLog(businessName = "分页查询文章列表的数据")
    public ResponseResult articleList(Integer pageNum,Integer pageSize,Long categoryId){

        return articleService.articleList(pageNum,pageSize,categoryId);
    }


    /**
     * 这里是展示文章详情的功能
     */
    @GetMapping(value = "/{id}")
    @SystemLog(businessName = "展示文章详情")
    public ResponseResult getArticleDetail(@PathVariable("id") Long id){

        return articleService.getArticleDetail(id);
    }


    /**
     * 这里是更新浏览量的功能
     */
    @PutMapping(value = "/updateViewCount/{id}")
    @SystemLog(businessName = "更新浏览量的功能")
    public ResponseResult updateViewCount(@PathVariable("id") Long id){

        return articleService.updateViewCount(id);
    }

}
